<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ContentArticleAdd extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'bail|required|string|min:1|max:40',
            'album_id'=>'bail|required',
            'group_id'=>'bail|required',
            'cover' => 'bail|string',
            'type' => ['bail','required',Rule::in(['2', '3']),],
            'content' => 'bail|required|string'
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '标题不能为空',
            'title.min' => '标题不能少于1个字',
            'title.max' => '标题不能大于40个字',
            'group_id.required' => '圈子不能为空',
            'album_id.required' => '专辑不能为空',
            'cover.required' => '封面图片不能为空',
            'type.required' => '请选择发布还是存草稿',
            'content.required' => '文本内容不能为空',
        ];
    }
}
